<template>
    <div>
        <div data-role="page" id="pageone">
            <!--<section class="part-user-info">
                <div class="left-info">
                    <div class="users">
                        <div class="head-portrait">
                            <img :src="accountinfo.headimgurl" alt="">
                        </div>
                        <div class="login-reg">
                            ID:000{{accountinfo.userId}}
                        </div>
                    </div>
                    <p class="xj-shouyi">现金收益（元）</p>
                </div>
                <div class="right-info">
                    <div class="change-identity">
                        <div class="business">
                            <i class="icon"></i>
                            <p class="text"><router-link :to="{name:'Business'}">商家</router-link></p>
                        </div>
                        <span class="line"></span>
                        <div class="personal">
                            <router-link :to="{name:'Mine'}" data-ajax="false">
                                <i class="icon"></i>
                                <p class="text">个人</p>
                            </router-link>
                        </div>
                    </div>
                    <p class="shouyi-mx">查看收益明细> </p>
                </div>

                <div class="user-num jinqian">{{money.companyAmount |amountMin100(2)}}</div>
            </section>-->
            <section class="part-user-info">
                <div class="top-info">
                    <div class="users left">
                        <router-link :to="{name:'Business_shop_set'}">
                            <div class="head-portrait">
                              <img :src="accountinfo.headimgurl" alt="">
                           </div>
                        </router-link>
                        <div class="login-reg">
                            {{accountinfo.companyName}}
                        </div>
                        <div class="login-reg">
                            ID:00{{companyId}}
                        </div>

                    </div>
                    <div class="change-identity">
                        <div class="business">
                            <router-link :to="{name:'Business'}" class="shangjia_mine">
                                <i class="icon"></i>
                                <p class="text">商家</p>
                            </router-link>
                        </div>
                        <span class="line"></span>
                        <div class="personal">
                            <router-link :to="{name:'Mine'}" data-ajax="false">
                                <i class="icon"></i>
                                <p class="text">个人</p>
                            </router-link>
                        </div>
                    </div>
                </div>
                <div class="bottom-info">
                    <p class="xj-shouyi">现金收益（元）</p>
                    <p class="shouyi-mx" @click="mqh" v-show="false">查看收益明细 > </p>
                </div>
                <router-link :to="{name:'busCash_eamings',query:{id:accountinfo.companyId}}"> <div class="user-num jinqian">{{money.companyBalance |amountMin100(2)}}</div></router-link>
            </section>
            <!--商家订单:to="{name:'busCash_eamings',query:{id:accountinfo.companyId}}-->
            <section class="business-order">
                <div class="top-info">
                    <span class="left-text">商家订单</span>
                    <router-link href="order/order.html" class="more-order" data-ajax="false" :to="{name:'Business_order' ,query: { id:-1,comid:companyId}}">查看更多订单> </router-link>
                </div>
                <div class="bottom-info">
                    <div class="same-box same-box1" @click="href(0)">
                        <i class="icon"></i>
                         <span class="icon1" v-if="Notpaying>0">{{Notpaying}}</span>
                        <p class="text"  style="text-align:center;">未付款</p>
                    </div>
                    <div class="same-box same-box2"  @click="href(1)">
                        <i class="icon"></i>
                         <span class="icon1" v-if="Payment>0">{{Payment}}</span>
                        <p class="text" style="text-align:center;">已付款</p>
                    </div>
                    <div class="same-box same-box3"  @click="href(2)">
                        <i class="icon"></i>
                        <span class="icon1" v-if="JOrderCount>0">{{JOrderCount}}</span>
                        <p class="text" style="text-align:center;">评价</p>
                    </div>
                    <div class="same-box same-box4" @click="shouhou">
                        <i class="icon"></i>
                        <p class="text" style="text-align:center;">售后</p>
                    </div>
                </div>
            </section>

            <!--设置-->
            <section class="mine-setinfo">
                <ul class="list-ul">
                    <router-link :to="{name:'Business_rz_qr_code',params:{id:accountinfo.userId,cmid:accountinfo.companyId,companyName:accountinfo.companyName}}" data-transition="slide" class="href-icon">
                        <li class="list-li">
                            <i class="l-icon l-icon1"></i>
                            <span>二维码</span>
                            <router-link :to="{name:'Business_rz_qr_code',params:{id:accountinfo.userId,cmid:accountinfo.companyId,companyName:accountinfo.companyName}}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>
                    <router-link :to="{name:'Business_shop_set'}" data-transition="slide" class="href-icon">
                        <li class="list-li">
                            <i class="l-icon l-icon2"></i>
                            <span>店铺设置</span>
                            <router-link :to="{name:'Business_shop_set'}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>
                    <router-link :to="{name:'Business_category_ad'}" class="href-icon">
                        <li class="list-li list-li-zk" style="border-top:1px solid #e5e5e5;">
                            <i class="l-icon l-icon4-1"></i>
                            <span>产品类目</span>
                            <router-link :to="{name:'Business_category_ad'}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>
                    <router-link :to="{name:'Business_release_product',query:{cmid:accountinfo.companyId}}" data-transition="slide" class="href-icon">
                        <li class="list-li">
                            <i class="l-icon l-icon3"></i>
                            <span>产品发布</span>
                            <router-link :to="{name:'Business_release_product',query:{cmid:accountinfo.companyId}}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>
                    <router-link :to="{name:'Business_Cp_manage',query:{spectype:'discount',cmid:accountinfo.companyId}}" data-transition="slide" class="href-icon">
                        <li class="list-li">
                            <i class="l-icon l-icon4"></i>
                            <span>产品管理</span>
                            <router-link :to="{name:'Business_Cp_manage',query:{spectype:'discount',cmid:accountinfo.companyId}}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>

                    <router-link :to="{name:'Business_discount_set',params:{id:compID}}" data-transition="slide" class="href-icon">
                        <li class="list-li">
                            <i class="l-icon l-icon5"></i>
                            <span>满减管理</span>
                            <router-link :to="{name:'Business_discount_set'}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>
                    <router-link :to="{path:'me_drainage',query:{companyid:accountinfo.companyId}}" data-transition="slide" class="href-icon">
                        <li class="list-li">
                            <i class="l-icon l-icon6"></i>
                            <span>引流入口</span>
                            <router-link :to="{name:'Business_drainage'}" data-transition="slide" class="href-icon">
                                <i class="icon"></i>
                            </router-link>
                        </li>
                    </router-link>
                </ul>
            </section>
            <div class="zhanwei"></div>
        </div>
        <business_footer :pageName="'busiMine'"></business_footer>
    </div>
</template>
<style scoped>
    @import "../../assets/business/css/index.css";
</style>
<script>
    import business_footer from "@/components/business_footer"
    export default {
        components: {
            business_footer
        },
        data() {
            return {
                ///api/wallet?userId=1&page=1&rows=1
                accountinfo: {},
                money: {},
                compID: 0,
                imgurl: '',
                companyId:'',
                JOrderCount:0,
                Payment:0,
                Notpaying:0,
                sess:1
            }
        },
        created(){
            this.getwxconfig();

            
        },
        mounted() {
            this.loadaccoutinfo();
            this.sess=sessionStorage.getItem('sess')
            console.log(this.sess)
            if(this.sess==1||this.sess==null||this.sess==''){
            var newgoods=confirm('新版商城已上线，前往新版商城')
           if(newgoods==true){
               this.$router.push({name:'me_index'})
           }else{
            this.sess=2
            sessionStorage.setItem('sess',this.sess)
           }
            }
         
        },

        methods: {
            shouhou:function(){
               layer.msg("暂未开通")
             },
            href(type){
                this.$router.push({ name: "Business_order", query: { id:type ,comid:this.companyId} })
            },
            loadaccoutinfo: function () {
                this.$http.get(this.APIURL_PREFIX + '/api/companyInfo').then((response) => {
                    this.accountinfo = response.data.data;
                    this.compID = this.accountinfo.companyId;
                    this.loadwalletinfo();
                    this.OrderCount();
                    this.PaymentHasBeen();
                    this.PaymentHasBeen1();
                }).catch(function (err) {
                    console.log(err)
                }).then();

                this.$http.get(this.APIURL_PREFIX + '/api/wap/accounts/info').then((response) => {
                    this.imgurl = response.data.data.headimgurl
                }).catch(function (err) {
                    console.log(err)
                }).then();

            },
            loadwalletinfo: function () {
                this.$http.get(this.APIURL_PREFIX + "/api/wap/company/wallet?page=1&rows=1").then((response) => {
                    this.money = response.data.data[0];
                    this.companyId=response.data.data[0].companyId
                }).catch(function (err) {
                    console.log(err)
                });
            },
          OrderCount(){//待评价个数
                this.$http.get(this.APIURL_PREFIX+'/api/wap/selectForOrderCompanyCount',{params:{orderStatus:2,companyId:this.compID}}).then((response) => {
                            this.JOrderCount=response.data.data
                            console.log(this.JOrderCount)
                        }).catch(function(err){

                        })

        },
         PaymentHasBeen(){//已付款
             this.$http.get(this.APIURL_PREFIX+'/api/wap/selectForOrderCompanyCount',{params:{payStatus:1,companyId:this.compID}}).then((response) => {
                            this.Payment=response.data.data
                        }).catch(function(err){

        })
        },
        PaymentHasBeen1(){//未付款
             this.$http.get(this.APIURL_PREFIX+'/api/wap/selectForOrderCompanyCount',{params:{payStatus:0,companyId:this.compID}}).then((response) => {
                            this.Notpaying=response.data.data
                            console.log(this.Notpaying)
                        }).catch(function(err){

        })
        },
            zwkt: function () {

            },
            mqh: function () {
               layer.msg("暂无收益")
            },


            getwxconfig() {
                var vm = this;
                this.$http.get(this.APIURL_PREFIX + "/api/wxs/config?url=" + escape(location.href.split('#')[0])).then((response) => {
                    console.log(response.data);
                    var appid = 'wx488ae3f57360b7ea';
                    wx.config({
                        debug: false,
                        appId: appid,
                        timestamp: response.data.data.timestamp,
                        nonceStr: response.data.data.noncestr,
                        signature: response.data.data.signature,
                        jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'scanQRCode', 'getLocation']
                    });
                    wx.ready(function () {
                         wx.onMenuShareTimeline({
                            title: "欢迎入驻首象共享",
                            link: "http://"+window.location.host+"/wap/wx/login?fk=1-42-"+localStorage.headid+"-no",
                            desc:"缺客户，上首象",
                            imgUrl:"http://static.ruitaowang.com/attached/file/2018/11/06/20181106144126178.jpg",
                            success: function () {
                            },
                            cancel: function () {
                            }
                        });
                        wx.onMenuShareAppMessage({
                             title: "欢迎入驻首象共享",
                            link: "http://"+window.location.host+"/wap/wx/login?fk=1-42-"+localStorage.headid+"-no",
                            desc:"缺客户，上首象",
                            imgUrl:"http://static.ruitaowang.com/attached/file/2018/11/06/20181106144126178.jpg",
                            success: function () {
                            },
                            cancel: function () {
                            }
                        });
                        wx.onMenuShareQQ({
                            title: "欢迎入驻首象共享",
                            link: "http://"+window.location.host+"/wap/wx/login?fk=1-42-"+localStorage.headid+"-no",
                            desc:"缺客户，上首象",
                            imgUrl:"http://static.ruitaowang.com/attached/file/2018/11/06/20181106144126178.jpg",
                            success: function () {
                            },
                            cancel: function () {
                            }
                        });
                        wx.onMenuShareWeibo({
                            title: "欢迎入驻首象共享",
                            link: "http://"+window.location.host+"/wap/wx/login?fk=1-42-"+localStorage.headid+"-no",
                            desc:"缺客户，上首象",
                            imgUrl:"http://static.ruitaowang.com/attached/file/2018/11/06/20181106144126178.jpg",
                            success: function () {
                            },
                            cancel: function () {
                            }
                        });
                        wx.onMenuShareQZone({
                            title: "欢迎入驻首象共享",
                            link: "http://"+window.location.host+"/wap/wx/login?fk=1-42-"+localStorage.headid+"-no",
                            desc:"缺客户，上首象",
                            imgUrl:"http://static.ruitaowang.com/attached/file/2018/11/06/20181106144126178.jpg",
                            success: function () {
                            },
                            cancel: function () {
                            }
                        });


                    });
                }).catch(function (err) {
                    console.log(err)
                });

            }
        },








        }
</script>
